/**
 * 
 */

package CCT220_Aula13_Exercicio01a_13106;


import java.util.Vector;


/**
 * ******************************
 * Project: CCT220
 * Package: CCT220_Aula13_Exercicio01_13106
 * Class: ControleDisciplina
 * Last Change: 29/09/2011 13:03:30
 * Description:
 * ******************************
 * 
 * @author marcel
 * @author 13106
 * 
 */
public class ControleDisciplina {
	private final Vector listaDisciplina = new Vector();


	/**
	 * ******************************
	 * Package: CCT220_Aula13_Exercicio01_13106
	 * Class: ControleDisciplina
	 * Method: insereDisciplina
	 * Last Change: 29/09/2011 13:04:31
	 * Description:
	 * ******************************
	 * 
	 * @param pCodigo
	 * @param pNome
	 * @param pCargaHoraria
	 */
	public void insereDisciplina(int pCodigo, String pNome, int pCargaHoraria) {

		Disciplina disc = new Disciplina(pCodigo, pNome, pCargaHoraria);
		listaDisciplina.add(disc);
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula13_Exercicio01_13106
	 * Class: ControleDisciplina
	 * Method: imprimeDisciplinas
	 * Last Change: 29/09/2011 13:04:35
	 * Description:
	 * ******************************
	 * 
	 * @return string
	 */
	public String imprimeDisciplinas() {

		String result = "";
		for (int intIdx = 0; intIdx < listaDisciplina.size(); intIdx++) {
			Disciplina disc = (Disciplina) listaDisciplina.elementAt(intIdx);
			result += imprimeDisciplina(disc.getCodigo());
		}
		return result;
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula13_Exercicio01_13106
	 * Class: ControleDisciplina
	 * Method: imprimeDisciplina
	 * Last Change: 29/09/2011 13:04:59
	 * Description:
	 * ******************************
	 * 
	 * @param pCodigo
	 * @return String
	 */
	public String imprimeDisciplina(int pCodigo) {

		for (int intIdx = 0; intIdx < listaDisciplina.size(); intIdx++) {
			if (((Disciplina) listaDisciplina.elementAt(intIdx)).getCodigo() == pCodigo) { return "Código: "
			        + ((Disciplina) listaDisciplina.elementAt(intIdx))
			                .getCodigo()
			        + " Nome: "
			        + ((Disciplina) listaDisciplina.elementAt(intIdx))
			                .getNome()
			        + " Carga horaria: "
			        + ((Disciplina) listaDisciplina.elementAt(intIdx))
			                .getCargaHoraria(); }
		}
		return "";
	}
}
